package com.example.haxballandroid;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class UsernameActivity extends Activity {

	
	private Intent initIntent;		//starts the service for the first time upon application launch
	public final static String MESSAGE = "com.example.haxballandroid.MESSAGE";
	
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_username);
		initIntent = new Intent(this, ActionUpdate.class);
		startService(initIntent);	

	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_username, menu);
		return true;
	}
	
	/** Called when the user clicks the Send button */
	public void setUsername(View view){
		//Get username
		EditText editText = (EditText) findViewById(R.id.set_username);
		String message = editText.getText().toString();
		
		Intent intentAct = new Intent(this, MenuActivity.class);
		initIntent.putExtra(MESSAGE, "username");				
		initIntent.putExtra("UserName", message);
		

		startService(initIntent);	
		startActivity(intentAct);

		finish();
		
	}
	
	/*
	@Override
	public void onResume(){
		super.onResume();
		startService(intent);
	}
	
	@Override
	public void onPause(){
		super.onPause();
		//stopService(intent);
	}
	
	*/
	

}
